package domain;


import enums.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class TableDataInfo {

    // 状态码
    private int code;
    // 提示信息
    private String msg;

    private List<?> rows;

    private long total;


    /**
     * 表格数据对象
     * @param rows
     * @param total
     * @return
     */
    public static TableDataInfo success(List<?> rows, long total)
    {
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(ResultCode.SUCCESS.getCode());
        rspData.setMsg(ResultCode.SUCCESS.getMsg());
        rspData.setRows(rows);
        rspData.setTotal(total);
        return rspData;
    }

    /**
     * 表格数据对象
     * @return
     */
    public static TableDataInfo empty()
    {
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(ResultCode.SUCCESS.getCode());
        rspData.setMsg(ResultCode.SUCCESS.getMsg());
        return rspData;
    }


}
